/*
 * Copyright 2010-2012 Susanta Tewari. <freecode4susant@users.sourceforge.net>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package coalescent.cef.pui;

import cef.event.Event;
import cef.pui.EventConstructionException;
import cef.pui.EventImpl;
import cef.pui.pob.Builder;
import cef.pui.pob.BuilderException;

import coalescent.cef.event.VisualizeGeneTreeEvent;
import coalescent.cef.pui.pob.Builders;
import coalescent.phylogeny.GeneTree;

import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

/**
 * Implements {@code VisualizeGeneTreeEvent} using the following properties.
 * <ul>
 * <li>{@code coalescent.builder.GeneTree.theta = valid double string as specified in } {@link Double#parseDouble(java.lang.String)}</li>
 * <li>{@code coalescent.builder.GeneTree.url = stringk69data:xml//URL}<a href="coalescent/cef/pui/pob/doc-files/k69data.xml.txt">file format</a>, must accompany the <a href="coalescent/cef/pui/pob/doc-files/k69data.xsd.txt">schema</a></li>
 * </ul>
 *
 * @author Susanta Tewari
 * @version 2.0.0
 * @history Created on 12/21/2010.
 * @since 1.3.0
 */
public final class VisualizeGeneTreeEventImpl extends EventImpl implements VisualizeGeneTreeEvent {

    /** Field description */
    private Builder<GeneTree> gtBuilder;

    /**
     * Constructs ...
     *
     *
     * @param props
     *
     * @throws EventConstructionException
     */
    public VisualizeGeneTreeEventImpl(Properties props) throws EventConstructionException {

        super(props);

        super.processEventProperties(getImplementedEventInterfaces());

        gtBuilder = Builders.getGeneTreeBuilderFileBased(props);

        addBuilder(gtBuilder);
    }

    /**
     * Method description
     *
     *
     * @return
     */
    @Override
    protected List<Class<? extends Event>> getImplementedEventInterfaces() {

        List<Class<? extends Event>> result = new ArrayList<>(2);

        result.add(VisualizeGeneTreeEvent.class);
        result.add(Event.class);

        return result;
    }

    /**
     * {@inheritDoc}
     * @throws BuilderException
     */
    @Override
    public GeneTree getGeneTree() throws BuilderException {
        return gtBuilder.build();
    }
}
